package com.brotherly.framework.service;

import java.util.HashMap;
import java.util.Map;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import android.telephony.TelephonyManager;

import com.brotherly.mpgp.R;

public class ServiceHost extends Service
{
    protected Map<String, IService> iServices;

    public static boolean debug = false;
    public static String releaseName = "";
    public static String deviceId = "";
    public static String softVer = "";
    public static String version = "";
    public static int androidVer = Build.VERSION.SDK_INT;

    public ServiceHost()
    {
        iServices = new HashMap<String, IService>();
    }

    public void putBinder(String action, IService binder)
    {
        iServices.put(action, binder);
    }

    public IService getService(String action)
    {
        IService iService = iServices.get(action);
        return iService;
    }

    @Override
    public void onCreate()
    {
        super.onCreate();

        try
        {
            debug = Boolean.parseBoolean(getString(R.string.debug_mark));
            releaseName = getString(R.string.release_name);
            version = getString(R.string.version);

            TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

            deviceId = telephonyManager.getDeviceId();
            softVer = telephonyManager.getDeviceSoftwareVersion();

            if (debug)
            {
                // Debug.waitForDebugger();
            }

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    @Override
    public IBinder onBind(Intent intent)
    {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId)
    {
        return super.onStartCommand(intent, flags, startId);
    }
}
